#pragma once

#include <gl\GL.h>
#include <gl\GLU.h>

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")


// COpenGLControl
class COpenGLControl : public CWnd
{
	DECLARE_DYNAMIC(COpenGLControl)

public:
	UINT_PTR	m_unpTimer;	// Timer

	/// <summary>
	/// variables for camera functions -- zoom, translate, rotate
	/// </summary>
	float		m_fLastX;
	float		m_fLastY;
	float		m_fPosX;
	float		m_fPosY;
	float		m_fZoom;
	float		m_fRotX;
	float		m_fRotY;

	/// <summary>
	/// drawing scene variables
	/// </summary>
	volatile GLfloat	value[4];	// value to be displayed
	volatile GLfloat	target[4];	// target value
	GLUquadricObj	*quadratic;	// storage for our quadratic objects
								// such as spheres, cubes, etc

	/// <summary>
	/// openGl color definitions
	/// </summary>
	static GLfloat	global_ambient[4];	// ambient light
	static GLfloat	light0Pos[4];
	static GLfloat	light0Amb[4];
	static GLfloat	light0Diff[4];
	static GLfloat	light0Spec[4];

	static GLfloat	light1Pos[4];
	static GLfloat	light1Amb[4];
	static GLfloat	light1Diff[4];
	static GLfloat	light1Spec[4];

	static GLfloat	shadow_ambient[4];
	static GLfloat	shadow_diffuse[4];
	static GLfloat	shadow_shiny;
	static GLfloat	shadow_specular[4];

	static GLfloat	wall_color[4];
	static GLfloat	wall_ambient[4];
	static GLfloat	floor_color[4];
	static GLfloat	column_color[4];
	static GLfloat	column_ambient[4];
	
	static GLfloat	cube_color[4];
	static GLfloat	cube_shiny;
	static GLfloat	cube_specular[4];
	static GLfloat	cube_ambient[4];
	
	static GLfloat	lamp_post_diffuse[4];
	static GLfloat	lamp_post_specular[4];
	static GLfloat	lamp_post_ambient[4];

	static GLfloat target_ambient[4];
	static GLfloat target_diffuse[4];
	static GLfloat target_specular[4];

	static GLfloat target_post_diffuse[4];
	static GLfloat target_post_specular[4];
	static GLfloat target_post_ambient[4];

	// Generic colors
	static GLfloat specular[4];
	static GLfloat emissive[4];
	static GLfloat shininess;

private:
	/// <summary>
	/// window information -- Microsoft Windows specific
	/// </summary>
	CWnd		*hWnd;
	HDC			hdc;
	HGLRC		hrc;
	int			m_nPixelFormat;

public:
	COpenGLControl();
	virtual ~COpenGLControl();

	void oglCreate(CRect rect, CWnd *parent); // setup the Windows specific variables 
	void oglInitialize(void); // setup up information OpenGL needs to render
	void oglDrawScene(void); // draw the openGL scene

	void oglDrawHMScene(void);
	void oglHMSceneInit(void);
	void drawTarget(void);

	void SetTargetMaterial(void);

public:
	afx_msg void OnPaint();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnDraw(CDC *pDC);
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnTimer(UINT_PTR nIDEvent);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);

protected:
	DECLARE_MESSAGE_MAP()
	
};




